package com.timo.redis.util;

import lombok.Getter;
import org.springframework.http.HttpStatus;

/**
 * @Description: 类的详细说明
 * @Author: timo
 * @Date: 2019/8/26 10:52
 */
@Getter
public enum ResultCode {

    /**
     * ######################
     * #        10 表示管理后台
     * ######################
     */
    // 01 表示是用户模块
    SYS_USER_NOT_LOGGED_IN(10_01_00001L,"User not logged in"),


    /**
     * ######################
     * #        通用的
     * ######################
     */


    REQUEST_FAIL_000_CODE(0L,"未知错误，如果需要请联系我们"),

    /**
     * 请求失败
     */
    REQUEST_FAIL_500_CODE(500L,"请求失败"),

    /**
     * 请求成功
     */
    REQUEST_SUCCESS_CODE(Long.valueOf(HttpStatus.OK.value()),"请求成功",true);

    public static ResultCode getResultCode(Long code) {
        for (ResultCode resultCode : ResultCode.values()) {
            if (resultCode.code.equals(code)) {
                return resultCode;
            }
        }
        return null;
    }


    public Long code;
    public String msg;
    public Boolean isSuccess = false;

    ResultCode(Long code, String msg, Boolean isSuccess) {
        this.code = code;
        this.msg = msg;
        this.isSuccess = isSuccess;
    }

    ResultCode(Long code, String msg) {
        this.code = code;
        this.msg = msg;
    }


}